<template>
    <el-dialog
            :center="true"
            :show-close="true"
            :visible="show"
            @close="close"
            lock-scroll
            title="机构注册">
        <el-form label-width="80px">
            <el-form-item class="marginBottom" label="机构名称" prop="name">
                <el-input class="borderNone" clearable placeholder="机构名称" v-model="sub.name"></el-input>
            </el-form-item>
            <el-form-item class="marginBottom">
                <el-button @click="submit" type="primary">提交申请</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
</template>

<script>
  export default {
    name: "OfficeAdd",
    props : {
      show : {
        type : Boolean,
        default : false,
      },
      userId : {
        type : String,
      }
    },
    data(){
      return {
        sub : {
          name : "",
          // 所属用户
          userId: this.userId,
          date :new Date().toLocaleDateString(),
        },
      }
    },
    methods : {
      submit(){
        this.$api.office.officeAdd(this.sub)
            .then(response => {
              console.log(response);
              this.$message({
                message : "添加成功",
                type : "success"
              });
              this.close();

            })
            .catch(error => {
              this.$message.error("添加失败!");
              console.log(error)
            })
      },
      close(){
        this.$emit("close");
      }
    }
  }
</script>

<style scoped>

</style>
